<?php
/**
 * @file
 * Displays the friends invitation form.
 *
 * Usage:
 *  - A page that wants to display the friends invitation form should
 *    include/require this page (once).
 *
 * Parameter(s):
 *  - $PATH_COMMON         : Relative path from the calling page to the 'common'
 *                           directory (e.g. '../common/').
 *  - APP_NAME             : The application's name.
 *  - APP_DESCRIPTION      : The application's description.
 *                           Warning: Double quotes in the content string will
 *                           screw up the invite signature process. Do not use
 *                           'htmlentities()' or 'urlencode()'.
 *  - FB_APP_URL_CANVAS    : The application's Facebook 'Canvas URL'.
 *  - FB_APP_INVITE_TITLE  : The application's invitation title text.
 *  - FB_APP_INVITE_BUTTON : The application's invitation button label.
 *
 * Global variable(s) set:
 *  - None.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - fb_facebook.php
 *  - fb_js_iframe_resize.php
 *  - fb_js_xfbml.php
 */

// constant(s) =================================================================
//! Request Form: Submit method.
define("FB_RQFO_METHOD", "POST");
//! Request Form: Flag for invitation.
define("FB_RQFO_INVITE", "true");

//! Multi-Friend-Selector: Border setting.
define("FB_MFS_BORDER", "false");
//! Multi-Friend-Selector: Bypass button type.
define("FB_MFS_BYPASS", "cancel");
//! Multi-Friend-Selector: Email invitation section setting.
define("FB_MFS_EMAIL_INVITE", "true");
//! Multi-Friend-Selector: Number of rows to show (without scrolling).
define("FB_MFS_ROWS", "4");
//! Multi-Friend-Selector: Number of columns to show.
define("FB_MFS_COLS", "5");
//! Multi-Friend-Selector: Maximum number of users that can be selected.
define("FB_MFS_MAX", "20");
//! Multi-Friend-Selector: Target frame.
define("FB_MFS_TARGET", "_top");


// implementation ==============================================================
// create request box fbml
$content = APP_DESCRIPTION
         . '<fb:req-choice'
         . ' url=\'' . FB_APP_URL_CANVAS . '\''
         . ' label=\'' . FB_APP_INVITE_BUTTON . '\''
         . ' />';
?>
<fb:serverfbml>
  <script type="text/fbml">
    <fb:fbml>
      <fb:request-form
        type="<?php echo APP_NAME ?>"
        content="<?php echo $content ?>"
        action="<?php echo FB_APP_URL_CANVAS ?>"
        method="<?php echo FB_RQFO_METHOD ?>"
        invite="<?php echo FB_RQFO_INVITE ?>"
        target="<?php echo FB_MFS_TARGET ?>"
      >
        <fb:multi-friend-selector
          actiontext="<?php echo FB_APP_INVITE_TITLE ?>"
          showborder="<?php echo FB_MFS_BORDER ?>"
          bypass="<?php echo FB_MFS_BYPASS ?>"
          email_invite="<?php echo FB_MFS_EMAIL_INVITE ?>"
          rows="<?php echo FB_MFS_ROWS ?>"
          cols="<?php echo FB_MFS_COLS ?>"
          max="<?php echo FB_MFS_MAX ?>"
          exclude_ids="<?php echo $exclude_friends_str ?>"
          target="<?php echo FB_MFS_TARGET ?>"
        />
      </fb:request-form>
    </fb:fbml>
  </script>
</fb:serverfbml>
<script type="text/javascript">
<?php require $PATH_COMMON . "php/fb_js_iframe_resize.js.php" ?>
</script>
<?php require_once $PATH_COMMON . "php/fb_js_xfbml.php"; ?>
